﻿using System.Numerics;
using System.Xml.Linq;
using Wenyu.Framework.Common.EnumTypes;
using Wenyu.Framework.Common.Helpers;
using Wenyu.Framework.DbModels;
using Wenyu.Framework.DbModels.Entities;

namespace Wenyu.Framework.InitDatabase
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string connString = "Data Source=.;Initial Catalog=Wenyu.Framework.DB;User ID=sa;Password=123456";
            

            using(FrameworkDbContext context=new FrameworkDbContext(connString))
            {
                //根据数据库连接字符串的配置，如果不存在就不操作
                context.Database.EnsureDeleted();
                //根据数据库连接字符串的配置，如果存在就不创建
                context.Database.EnsureCreated();
                Console.WriteLine("数据库创建成功");


                context.Set<UserEntity>().Add(new UserEntity()
                {
                    Name="xiewenyu",
                    UserName="admin",
                    Password=Md5Helper.Encrypt("123456"),
                    Age =18,
                    UserType=UserTypeEnum.Administrator,
                    Phone="12323234545"
                });
                context.SaveChanges();


                Console.WriteLine("数据库数据初始化完成");
            }

            //Console.WriteLine("数据库创建成功");



        }
    }
}